Use YongTest;
Go
Print 'Database selected';

Print 'Check Table exists';
If Exists(select 1 from Sys.objects where object_ID=object_ID('FlightDeparture') AND type in (N'U'))
Begin
	Print 'Table Exists';
	Drop Table FlightDeparture;
	Print 'FlightDeparture Table Dropped';
END
Print 'Creating FlightDeparture Table ';
Create Table FlightDeparture
(
	FlightID int identity (1,1),
	FlightCode char(6) not null,
	ScheduledDeparture datetime not null,
	ActualDeparture datetime null,
	DelayTime as (DateDiff(MINUTE, ScheduledDeparture, ActualDeparture)) PERSISTED
)
with
(
	Data_compression = ROW
)

go
Print 'Table Created';